package com.dommettj.rawfix.gui;

import com.dommettj.rawfix.gui.event.GuiEventCallback;
import com.dommettj.rawfix.message.MessageType;

import javax.swing.*;

public class GuiEventCallbackImpl implements GuiEventCallback {

    private JTextArea logBox;

    public GuiEventCallbackImpl(final JTextArea logBox) {

        this.logBox = logBox;
    }

    @Override
    public void logonFailure(String reason) {
        logBox.append("Logon failed: " + reason + "\n");
    }

    @Override
    public void logoffFailure(String reason) {
        logBox.append("Logoff failed: " + reason + "\n");
    }

    @Override
    public void messageReceived(MessageType messageType, String message) {
        logBox.append("Received [" + messageType + ": " + message + "]\n");
    }

    @Override
    public void messageSendFailure(String reason) {
        logBox.append("Failed to send message: " + reason + "\n");
    }
}
